/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cn.ac.iie.di.ban.news.server.check.checkers;

import cn.ac.iie.di.ban.news.server.check.CheckResult;
import cn.ac.iie.di.ban.news.server.check.Checker;

/**
 *
 * @author zwlin
 */
public class LongChecker implements Checker<String, String> {

    @Override
    public CheckResult check(String src, String target) {
        if (src == null || (src = src.trim()).isEmpty()) {
            return new CheckResult();
        }
        try {
            Long.parseLong(src);
        } catch (Exception e) {
            return new CheckResult("cannot be parsed to Long.");
        }
        return new CheckResult();
    }

}
